package com.itany.dao;

import com.itanty.maven.dao.entity.User;
import org.apache.ibatis.annotations.*;

/**
 * @date 2025/9/19
 */
public interface UserMapper {
    @Insert(value = "insert into t_user(username,password,phone,address) values (#{username},#{password},#{phone},#{address})")
    void insertUser(User user);

    @Delete(value = "delete from t_user where id = #{id}")
    void deleteById(Integer id);

    @Update(value = "update t_user set username = #{username} where id = #{id}")
    void updateUser(User user);

    @Select("select * from t_user where id = #{id}")
    User selectById(Integer id);

    @Select(value = "select user_id,user_username,user_password,user_phone,user_address from t_user2 where user_id = #{id}")
    @Results(value = {
            @Result(id = true,column = "user_id",property = "id"),
            @Result(column = "user_username",property = "username"),
            @Result(column = "user_password",property = "password"),
            @Result(column = "user_phone",property = "phone"),
            @Result(column = "user_address",property = "address")
    })
    User selectById2(Integer id);
}
